<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Cascader 级联选择器 | MyUI 4.x</title>
    <meta name="generator" content="VuePress 1.5.4">
    <link rel="icon" href="/my/favicon.ico">
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?c4e5f73318b5cb0c389e3d9a05f831cc";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
    <meta name="description" content="MyUI是美亚柏科旗下新德汇出品的Web前端一站式项目工程框架，专注于公检法行业中台系统快速搭建，框架已在多个项目实战检验。">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <link rel="preload" href="/my/assets/css/0.styles.810d4cba.css" as="style"><link rel="preload" href="/my/assets/js/app.2dbd0b81.js" as="script"><link rel="preload" href="/my/assets/js/493.009afff8.js" as="script"><link rel="preload" href="/my/assets/js/1299.72693287.js" as="script"><link rel="preload" href="/my/assets/js/1031.8d6cd2c9.js" as="script">
    <link rel="stylesheet" href="/my/assets/css/0.styles.810d4cba.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/my/" class="home-link router-link-active"><img src="/my/img/logo.png" alt="MyUI 4.x" class="logo"> <span class="site-name can-hide">MyUI 4.x</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/my/guide/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><a href="/my/ui/pages/" class="nav-link">
  页面
</a></div><div class="nav-item"><a href="http://newgateway.gitee.io/my-web/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  演示
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow down"></span></button> <button type="button" aria-label="JSDoc" class="mobile-dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/my/guide/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><a href="/my/ui/pages/" class="nav-link">
  页面
</a></div><div class="nav-item"><a href="http://newgateway.gitee.io/my-web/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  演示
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow down"></span></button> <button type="button" aria-label="JSDoc" class="mobile-dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Basic</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>Form</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/my/element/cascader.html" aria-current="page" class="active sidebar-link">Cascader 级联选择器</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my/element/cascader.html#基础用法" class="sidebar-link">基础用法</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#禁用选项" class="sidebar-link">禁用选项</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#可清空" class="sidebar-link">可清空</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#仅显示最后一级" class="sidebar-link">仅显示最后一级</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#多选" class="sidebar-link">多选</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#选择任意一级选项" class="sidebar-link">选择任意一级选项</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#动态加载" class="sidebar-link">动态加载</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#可搜索" class="sidebar-link">可搜索</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#自定义节点内容" class="sidebar-link">自定义节点内容</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#级联面板" class="sidebar-link">级联面板</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#cascader-attributes" class="sidebar-link">Cascader Attributes</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#cascader-events" class="sidebar-link">Cascader Events</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#cascader-methods" class="sidebar-link">Cascader Methods</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#cascader-slots" class="sidebar-link">Cascader Slots</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#cascaderpanel-attributes" class="sidebar-link">CascaderPanel Attributes</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#cascaderpanel-events" class="sidebar-link">CascaderPanel Events</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#cascaderpanel-methods" class="sidebar-link">CascaderPanel Methods</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#cascaderpanel-slots" class="sidebar-link">CascaderPanel Slots</a></li><li class="sidebar-sub-header"><a href="/my/element/cascader.html#props" class="sidebar-link">Props</a></li></ul></li><li><a href="/my/element/checkbox.html" class="sidebar-link">Checkbox 多选框</a></li><li><a href="/my/element/color-picker.html" class="sidebar-link">ColorPicker 颜色选择器</a></li><li><a href="/my/element/date-picker.html" class="sidebar-link">DatePicker 日期选择器</a></li><li><a href="/my/element/datetime-picker.html" class="sidebar-link">DateTimePicker 日期时间选择器</a></li><li><a href="/my/element/form.html" class="sidebar-link">Form 表单</a></li><li><a href="/my/element/input.html" class="sidebar-link">Input 输入框</a></li><li><a href="/my/element/input-number.html" class="sidebar-link">InputNumber 计数器</a></li><li><a href="/my/element/radio.html" class="sidebar-link">Radio 单选框</a></li><li><a href="/my/element/rate.html" class="sidebar-link">Rate 评分</a></li><li><a href="/my/element/select.html" class="sidebar-link">Select 选择器</a></li><li><a href="/my/element/slider.html" class="sidebar-link">Slider 滑块</a></li><li><a href="/my/element/switch.html" class="sidebar-link">Switch 开关</a></li><li><a href="/my/element/time-picker.html" class="sidebar-link">TimePicker 时间选择器</a></li><li><a href="/my/element/transfer.html" class="sidebar-link">Transfer 穿梭框</a></li><li><a href="/my/element/upload.html" class="sidebar-link">Upload 上传</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Data</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Notice</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Navigation</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Others</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="cascader-级联选择器"><a href="#cascader-级联选择器" class="header-anchor">#</a> Cascader 级联选择器</h1> <p>当一个数据集合有清晰的层级结构时，可通过级联选择器逐级查看并选择。</p> <h2 id="基础用法"><a href="#基础用法" class="header-anchor">#</a> 基础用法</h2> <p>有两种触发子菜单的方式</p> <!----><h2 id="禁用选项"><a href="#禁用选项" class="header-anchor">#</a> 禁用选项</h2> <p>通过在数据源中设置 <code>disabled</code> 字段来声明该选项是禁用的</p> <!----><h2 id="可清空"><a href="#可清空" class="header-anchor">#</a> 可清空</h2> <p>通过 <code>clearable</code> 设置输入框可清空</p> <!----><h2 id="仅显示最后一级"><a href="#仅显示最后一级" class="header-anchor">#</a> 仅显示最后一级</h2> <p>可以仅在输入框中显示选中项最后一级的标签，而不是选中项所在的完整路径。</p> <!----><h2 id="多选"><a href="#多选" class="header-anchor">#</a> 多选</h2> <p>可通过 <code>props.multiple = true</code> 来开启多选模式</p> <!----><h2 id="选择任意一级选项"><a href="#选择任意一级选项" class="header-anchor">#</a> 选择任意一级选项</h2> <p>在单选模式下，你只能选择叶子节点；而在多选模式下，勾选父节点真正选中的都是叶子节点。启用该功能后，可让父子节点取消关联，选择任意一级选项。</p> <!----><h2 id="动态加载"><a href="#动态加载" class="header-anchor">#</a> 动态加载</h2> <p>当选中某一级时，动态加载该级下的选项。</p> <!----><h2 id="可搜索"><a href="#可搜索" class="header-anchor">#</a> 可搜索</h2> <p>可以快捷地搜索选项并选择。</p> <!----><h2 id="自定义节点内容"><a href="#自定义节点内容" class="header-anchor">#</a> 自定义节点内容</h2> <p>可以自定义备选项的节点内容</p> <!----><h2 id="级联面板"><a href="#级联面板" class="header-anchor">#</a> 级联面板</h2> <p>级联面板是级联选择器的核心组件，与级联选择器一样，有单选、多选、动态加载等多种功能。</p> <!----><h2 id="cascader-attributes"><a href="#cascader-attributes" class="header-anchor">#</a> Cascader Attributes</h2> <table><thead><tr><th>参数</th> <th>说明</th> <th>类型</th> <th>可选值</th> <th>默认值</th></tr></thead> <tbody><tr><td>value / v-model</td> <td>选中项绑定值</td> <td>-</td> <td>—</td> <td>—</td></tr> <tr><td>options</td> <td>可选项数据源，键名可通过 <code>Props</code> 属性配置</td> <td>array</td> <td>—</td> <td>—</td></tr> <tr><td>props</td> <td>配置选项，具体见下表</td> <td>object</td> <td>—</td> <td>—</td></tr> <tr><td>size</td> <td>尺寸</td> <td>string</td> <td>medium / small / mini</td> <td>—</td></tr> <tr><td>placeholder</td> <td>输入框占位文本</td> <td>string</td> <td>—</td> <td>请选择</td></tr> <tr><td>disabled</td> <td>是否禁用</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>clearable</td> <td>是否支持清空选项</td> <td>boolean</td> <td>—</td> <td>false</td></tr> <tr><td>show-all-levels</td> <td>输入框中是否显示选中值的完整路径</td> <td>boolean</td> <td>—</td> <td>true</td></tr> <tr><td>collapse-tags</td> <td>多选模式下是否折叠Tag</td> <td>boolean</td> <td>-</td> <td>false</td></tr> <tr><td>separator</td> <td>选项分隔符</td> <td>string</td> <td>—</td> <td>斜杠' / '</td></tr> <tr><td>filterable</td> <td>是否可搜索选项</td> <td>boolean</td> <td>—</td> <td>—</td></tr> <tr><td>filter-method</td> <td>自定义搜索逻辑，第一个参数是节点<code>node</code>，第二个参数是搜索关键词<code>keyword</code>，通过返回布尔值表示是否命中</td> <td>function(node, keyword)</td> <td>-</td> <td>-</td></tr> <tr><td>debounce</td> <td>搜索关键词输入的去抖延迟，毫秒</td> <td>number</td> <td>—</td> <td>300</td></tr> <tr><td>before-filter</td> <td>筛选之前的钩子，参数为输入的值，若返回 false 或者返回 Promise 且被 reject，则停止筛选</td> <td>function(value)</td> <td>—</td> <td>—</td></tr> <tr><td>popper-class</td> <td>自定义浮层类名</td> <td>string</td> <td>—</td> <td>—</td></tr></tbody></table> <h2 id="cascader-events"><a href="#cascader-events" class="header-anchor">#</a> Cascader Events</h2> <table><thead><tr><th>事件名称</th> <th>说明</th> <th>回调参数</th></tr></thead> <tbody><tr><td>change</td> <td>当选中节点变化时触发</td> <td>选中节点的值</td></tr> <tr><td>expand-change</td> <td>当展开节点发生变化时触发</td> <td>各父级选项值组成的数组</td></tr> <tr><td>blur</td> <td>当失去焦点时触发</td> <td>(event: Event)</td></tr> <tr><td>focus</td> <td>当获得焦点时触发</td> <td>(event: Event)</td></tr> <tr><td>visible-change</td> <td>下拉框出现/隐藏时触发</td> <td>出现则为 true，隐藏则为 false</td></tr> <tr><td>remove-tag</td> <td>在多选模式下，移除Tag时触发</td> <td>移除的Tag对应的节点的值</td></tr></tbody></table> <h2 id="cascader-methods"><a href="#cascader-methods" class="header-anchor">#</a> Cascader Methods</h2> <table><thead><tr><th>方法名</th> <th>说明</th> <th>参数</th></tr></thead> <tbody><tr><td>getCheckedNodes</td> <td>获取选中的节点</td> <td>(leafOnly) 是否只是叶子节点，默认值为 <code>false</code></td></tr></tbody></table> <h2 id="cascader-slots"><a href="#cascader-slots" class="header-anchor">#</a> Cascader Slots</h2> <table><thead><tr><th>名称</th> <th>说明</th></tr></thead> <tbody><tr><td>-</td> <td>自定义备选项的节点内容，参数为 { node, data }，分别为当前节点的 Node 对象和数据</td></tr> <tr><td>empty</td> <td>无匹配选项时的内容</td></tr></tbody></table> <h2 id="cascaderpanel-attributes"><a href="#cascaderpanel-attributes" class="header-anchor">#</a> CascaderPanel Attributes</h2> <table><thead><tr><th>参数</th> <th>说明</th> <th>类型</th> <th>可选值</th> <th>默认值</th></tr></thead> <tbody><tr><td>value / v-model</td> <td>选中项绑定值</td> <td>-</td> <td>—</td> <td>—</td></tr> <tr><td>options</td> <td>可选项数据源，键名可通过 <code>Props</code> 属性配置</td> <td>array</td> <td>—</td> <td>—</td></tr> <tr><td>props</td> <td>配置选项，具体见下表</td> <td>object</td> <td>—</td> <td>—</td></tr></tbody></table> <h2 id="cascaderpanel-events"><a href="#cascaderpanel-events" class="header-anchor">#</a> CascaderPanel Events</h2> <table><thead><tr><th>事件名称</th> <th>说明</th> <th>回调参数</th></tr></thead> <tbody><tr><td>change</td> <td>当选中节点变化时触发</td> <td>选中节点的值</td></tr> <tr><td>expand-change</td> <td>当展开节点发生变化时触发</td> <td>各父级选项值组成的数组</td></tr></tbody></table> <h2 id="cascaderpanel-methods"><a href="#cascaderpanel-methods" class="header-anchor">#</a> CascaderPanel Methods</h2> <table><thead><tr><th>方法名</th> <th>说明</th> <th>参数</th></tr></thead> <tbody><tr><td>getCheckedNodes</td> <td>获取选中的节点数组</td> <td>(leafOnly) 是否只是叶子节点，默认值为 <code>false</code></td></tr> <tr><td>clearCheckedNodes</td> <td>清空选中的节点</td> <td>-</td></tr></tbody></table> <h2 id="cascaderpanel-slots"><a href="#cascaderpanel-slots" class="header-anchor">#</a> CascaderPanel Slots</h2> <table><thead><tr><th>名称</th> <th>说明</th></tr></thead> <tbody><tr><td>-</td> <td>自定义备选项的节点内容，参数为 { node, data }，分别为当前节点的 Node 对象和数据</td></tr></tbody></table> <h2 id="props"><a href="#props" class="header-anchor">#</a> Props</h2> <table><thead><tr><th>参数</th> <th>说明</th> <th>类型</th> <th>可选值</th> <th>默认值</th></tr></thead> <tbody><tr><td>expandTrigger</td> <td>次级菜单的展开方式</td> <td>string</td> <td>click / hover</td> <td>'click'</td></tr> <tr><td>multiple</td> <td>是否多选</td> <td>boolean</td> <td>-</td> <td>false</td></tr> <tr><td>checkStrictly</td> <td>是否严格的遵守父子节点不互相关联</td> <td>boolean</td> <td>-</td> <td>false</td></tr> <tr><td>emitPath</td> <td>在选中节点改变时，是否返回由该节点所在的各级菜单的值所组成的数组，若设置 false，则只返回该节点的值</td> <td>boolean</td> <td>-</td> <td>true</td></tr> <tr><td>lazy</td> <td>是否动态加载子节点，需与 lazyLoad 方法结合使用</td> <td>boolean</td> <td>-</td> <td>false</td></tr> <tr><td>lazyLoad</td> <td>加载动态数据的方法，仅在 lazy 为 true 时有效</td> <td>function(node, resolve)，<code>node</code>为当前点击的节点，<code>resolve</code>为数据加载完成的回调(必须调用)</td> <td>-</td> <td>-</td></tr> <tr><td>value</td> <td>指定选项的值为选项对象的某个属性值</td> <td>string</td> <td>—</td> <td>'value'</td></tr> <tr><td>label</td> <td>指定选项标签为选项对象的某个属性值</td> <td>string</td> <td>—</td> <td>'label'</td></tr> <tr><td>children</td> <td>指定选项的子选项为选项对象的某个属性值</td> <td>string</td> <td>—</td> <td>'children'</td></tr> <tr><td>disabled</td> <td>指定选项的禁用为选项对象的某个属性值</td> <td>string</td> <td>—</td> <td>'disabled'</td></tr> <tr><td>leaf</td> <td>指定选项的叶子节点的标志位为选项对象的某个属性值</td> <td>string</td> <td>—</td> <td>'leaf'</td></tr></tbody></table></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/my/element/typography.html" class="prev">
        Typography 字体
      </a></span> <span class="next"><a href="/my/element/checkbox.html">
        Checkbox 多选框
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/my/assets/js/app.2dbd0b81.js" defer></script><script src="/my/assets/js/493.009afff8.js" defer></script><script src="/my/assets/js/1299.72693287.js" defer></script><script src="/my/assets/js/1031.8d6cd2c9.js" defer></script>
  </body>
</html>
